package com.whw.springboot.bcucb.service.serviceImpl;

import com.whw.springboot.bcucb.entity.Comment;
import com.whw.springboot.bcucb.entity.Message;
import com.whw.springboot.bcucb.mapper.CommentMapper;
import com.whw.springboot.bcucb.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommentImpl implements CommentService {
    @Resource
    private CommentMapper commentMapper;

    @Override
    public Message<?> deleteByPrimaryKey(int commentId) {

        return commentMapper.deleteByPrimaryKey(commentId)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message<?> insert(Comment record) {

        return commentMapper.insert(record)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message<?> insertSelective(Comment record) {

        return commentMapper.insertSelective(record)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message<Comment> selectByPrimaryKey(int commentId) {
        return Message.success(null).add(commentMapper.selectByPrimaryKey(commentId));
    }

    @Override
    public Message<?> updateByPrimaryKeySelective(Comment record) {
        return commentMapper.updateByPrimaryKeySelective(record)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message<?> updateByPrimaryKey(Comment record) {

        return commentMapper.updateByPrimaryKey(record)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message<List<Comment>> selectAll() {
        return Message.success(null).add(commentMapper.selectAll());
    }
}
